<!DOCTYPE html>
<html lang="zh">
{% load static %}
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" />
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <meta name="keywords" content="YANGPIENA">
    <meta name="description" content="YANGPIENA">
    <meta name="author" content="YANGPIENA">
    <link rel="icon" href="{% static 'images/favicon.ico' %}" type="image/ico">
    <link rel="shortcut icon" href="{% static 'images/favicon.ico' %}" type="image/x-icon"/>
    <title>{{ SYS_TITLE }}</title>
    <link rel="stylesheet" href="{% static 'css/bootstrap.min.css' %}">
    <link rel="stylesheet" href="{% static 'css/materialdesignicons.min.css' %}">
    <link rel="stylesheet" href="{% static 'css/animate.css' %}">
    <link rel="stylesheet" href="{% static 'css/style.min.css' %}">
    <!-- DataTable -->
    <link rel="stylesheet" href="{% static 'plugins/dataTable/responsive.bootstrap.min.css' %}">
    <!-- 时间选择插件 -->
    <link rel="stylesheet" href="{% static 'plugins/bootstrap-datetimepicker/bootstrap-datetimepicker.min.css' %}">
    <!-- 日期选择插件 -->
    <link rel="stylesheet" href="{% static 'plugins/bootstrap-datepicker/bootstrap-datepicker3.min.css' %}">
    <!-- Select2 -->
    <link rel="stylesheet" href="{% static 'plugins/select2/select2.css' %}">
    <!-- 对话框 -->
    <link rel="stylesheet" href="{% static 'plugins/jconfirm/jquery-confirm.min.css' %}">

    {% block custome_css %}{% endblock %}
</head>

<body>
    <!-- 左侧导航 -->
    <aside class="lyear-layout-sidebar">

                <!-- logo -->
                <div id="logo" class="sidebar-header">
                    <a href="{% url 'index' %}">
                        <img src="{% static 'images/logo.png' %}"/>
                        <span class="logo-text">{{ SYS_TITLE }}</span>
                    </a>
                </div>
                <div class="lyear-layout-sidebar-scroll">

                    <nav class="sidebar-main">
                        <ul class="nav nav-drawer">
                            <li {% ifequal request.path '/' %}class="nav-item active"{% endifequal %}>
                                <a href="{% url 'index' %}"><i class="mdi mdi-home"></i> 首页</a>
                            </li>

                            {{ USER_MENU|safe }}

                        </ul>
                    </nav>
                </div>

            </aside>
    <!-- End 左侧导航 -->

    <!-- 头部信息 -->
    <header class="lyear-layout-header">
        <nav class="navbar navbar-default">
            <div class="topbar">

                <div class="topbar-left">
                    <div class="lyear-aside-toggler">
                        <span class="lyear-toggler-bar"></span>
                        <span class="lyear-toggler-bar"></span>
                        <span class="lyear-toggler-bar"></span>
                    </div>
                    <span class="navbar-page-title">{% block title %}{% endblock %}</span>
                </div>

                <ul class="topbar-right">
                    <li class="dropdown dropdown-profile">
                        <a href="javascript:void(0)" data-toggle="dropdown">
                            <img class="img-avatar img-avatar-36 m-r-10" src="/static/images/avatar/{{ request.user.avatar|default_if_none:'avatar.gif' }}"/>
                            <span>{{ request.user.name }}<span class="caret"></span></span>
                        </a>
                        <ul class="dropdown-menu dropdown-menu-right">
                            <li> <a href="#" onclick="modify_password();"><i class="mdi mdi-lock-outline"></i> 修改密码</a> </li>
                            <li> <a href="#" onclick="localStorage.clear();"><i class="mdi mdi-delete"></i> 清空缓存</a></li>
                            <li class="divider"></li>
                            <li> <a href="{% url 'systems:logout' %}" onclick="localStorage.setItem('check2',false);"><i class="mdi mdi-logout-variant"></i> 退出登录</a> </li>
                        </ul>
                    </li>
                </ul>

            </div>
        </nav>
    </header>
    <!-- End 头部信息 -->

    <!-- 页面主要内容 -->
    <main class="lyear-layout-content">
        <div class="container-fluid">
            <!-- 正文页面 -->
            {% block content %}{% endblock %}
        </div>
    </main>
    <!-- End 页面主要内容 -->

    <script type="text/javascript" src="{% static 'js/jquery.min.js' %}"></script>
    <script type="text/javascript" src="{% static 'js/bootstrap.min.js' %}"></script>
    <script type="text/javascript" src="{% static 'js/perfect-scrollbar.min.js' %}"></script>
    <!-- DataTable -->
    <script type="text/javascript" src="{% static 'plugins/dataTable/jquery.dataTables.min.js' %}"></script>
    <script type="text/javascript" src="{% static 'plugins/dataTable/dataTables.bootstrap4.min.js' %}"></script>
    <script type="text/javascript" src="{% static 'plugins/dataTable/dataTables.responsive.min.js' %}"></script>
    <script type="text/javascript" src="{% static 'js/init-datatable.js' %}"></script>
    <!-- 时间选择插件 -->
    <script type="text/javascript" src="{% static 'plugins/bootstrap-datetimepicker/moment.min.js' %}"></script>
    <script type="text/javascript" src="{% static 'plugins/bootstrap-datetimepicker/bootstrap-datetimepicker.min.js' %}"></script>
    <script type="text/javascript" src="{% static 'plugins/bootstrap-datetimepicker/locale/zh-cn.js' %}"></script>
    <!-- 日期选择插件 -->
    <script type="text/javascript" src="{% static 'plugins/bootstrap-datepicker/bootstrap-datepicker.min.js' %}"></script>
    <script type="text/javascript" src="{% static 'plugins/bootstrap-datepicker/locales/bootstrap-datepicker.zh-CN.min.js' %}"></script>
    <!--Select2 js-->
    <script type="text/javascript" src="{% static 'plugins/select2/select2.full.js' %}"></script>
    <!-- 消息提示 -->
    <script type="text/javascript" src="{% static 'js/bootstrap-notify.min.js' %}"></script>
    <script type="text/javascript" src="{% static 'js/lightyear.js' %}"></script>
    <!-- 对话框 -->
    <script type="text/javascript" src="{% static 'plugins/jconfirm/jquery-confirm.min.js' %}"></script>

    {% block custome_js %}{% endblock %}

    <script type="text/javascript" src="{% static 'js/main.min.js' %}"></script>
    <script>
        function modify_password() {
            $.ajax({
                type: "GET",
                url: '{% url 'systems:user_pwd_modify' %}',
                success: function (callback) {
                    $.confirm({
                        title: '修改密码',
                        content: callback,
                        {#content: 'URL:{% url 'systems:user_add' %}',#}
                        columnClass: 'col-md-6 col-md-offset-3',
                        {#theme: 'bootstrap',#}
                        {#boxWidth: '500px',#}
                        {#useBootstrap: false,#}
                        buttons: {
                            formSubmit: {
                                text: '保存',
                                btnClass: 'btn-success btn-w-sm',
                                action: function () {
                                    var form = this.$content.find('#form-add');
                                    if(form.length > 0){
                                        $.ajax({
                                            type: form.attr('method'),
                                            url: form.attr('action'),
                                            data: new FormData(form[0]),  // 为了兼容数据和文件均能正常提交，将data从form.serialize()更改为form_data
                                            processData: false,           // 告诉jQuery不要去处理发送的数据
                                            contentType: false,           // 告诉jQuery不要去设置Content-Type请求头
                                            //cache: false,               // 上传文件不需要缓存
                                            success: function (resp) {
                                                if (resp.code === "200") {
                                                    $.confirm({
                                                        title: '',
                                                        content: resp.msg,
                                                        type: 'green',
                                                        buttons: {
                                                            close: {
                                                                text: '关闭',
                                                                action: function(){
                                                                    location.href = "{% url 'systems:user_list' %}";
                                                                }
                                                            }
                                                        }
                                                    });
                                                } else {
                                                    $.alert(resp.msg);
                                                }
                                            },
                                            error: function () {
                                                lightyear.notify('系统异常', 'warning', 100);
                                            }
                                        });
                                    }
                                    return false;
                                }
                            },
                            cancel: {
                                text: '取消'
                            },
                        }
                    });
                },
                error: function () {
                    lightyear.notify('系统异常', 'warning', 100);
                }
            })
        }
    </script>

</body>
</html>
